SlideShare a Scribd company logo
1 of 17
Class No.25  Data Structures http://ecomputernotes.com
BuildHeap ,[object Object],[object Object],[object Object],[object Object],http://ecomputernotes.com
BuildHeap i = 15/2 = 7 65 19 21 14 24 26 13 15 68 16 65 21 19 26 14 16 68 13 24 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 31 31 11 32 32 12 15 4 5 13 70 14 12 15 5 70 12 i   i Why I=n/2? http://ecomputernotes.com
BuildHeap i = 15/2 = 7 65 19 21 14 24 26 13 15 12 16 65 21 19 26 14 16 12 13 24 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 31 31 11 32 32 12 15 4 5 13 70 14 68 15 5 70 68 i   i http://ecomputernotes.com
BuildHeap i = 6 65 19 21 14 24 26 13 15 12 16 65 21 19 26 14 16 12 13 24 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 31 31 11 32 32 12 15 4 5 13 70 14 68 15 5 70 68 i   i http://ecomputernotes.com
BuildHeap i = 5 65 5 21 14 24 26 13 15 12 16 65 21 5 26 14 16 12 13 24 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 31 31 11 32 32 12 15 4 19 13 70 14 68 15 19 70 68 i   i http://ecomputernotes.com
BuildHeap i = 4 65 5 14 21 24 26 13 15 12 16 65 14 5 26 21 16 12 13 24 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 31 31 11 32 32 12 15 4 19 13 70 14 68 15 19 70 68 i   i http://ecomputernotes.com
BuildHeap i = 3 65 5 14 21 24 13 26 15 12 16 65 14 5 13 21 16 12 26 24 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 31 31 11 32 32 12 15 4 19 13 70 14 68 15 19 70 68 i   i http://ecomputernotes.com
BuildHeap i = 2 65 16 14 21 24 13 26 15 12 32 65 14 16 13 21 32 12 26 24 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 31 31 11 5 5 12 15 4 19 13 70 14 68 15 19 70 68 i   i http://ecomputernotes.com
BuildHeap i = 1 65 16 14 21 31 24 26 15 12 32 65 14 16 24 21 32 12 26 31 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 13 13 11 5 5 12 15 4 19 13 70 14 68 15 19 70 68 i   i http://ecomputernotes.com
BuildHeap Min heap 5 16 14 21 31 24 26 15 65 32 5 14 16 24 21 32 65 26 31 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 13 13 11 12 12 12 15 4 19 13 70 14 68 15 19 70 68 http://ecomputernotes.com
Other Heap Operations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],http://ecomputernotes.com
Heap code in C++ template <class eType> class Heap { public: Heap( int capacity = 100 ); void insert( const eType & x ); void deleteMin( eType & minItem ); const eType & getMin( ); bool isEmpty( ); bool isFull( ); int Heap<eType>::getSize( ); http://ecomputernotes.com
Heap code in C++ private: int currentSize; // Number of elements in heap eType* array; // The heap array int capacity; void percolateDown( int hole ); }; http://ecomputernotes.com
Heap code in C++ #include &quot;Heap.h“ template <class eType> Heap<eType>::Heap( int capacity ) { array = new etype[capacity + 1]; currentSize=0; } http://ecomputernotes.com
Heap code in C++ // Insert item x into the heap, maintaining heap // order. Duplicates are allowed. template <class eType> bool Heap<eType>::insert( const eType & x ) { if( isFull( ) ) { cout << &quot;insert - Heap is full.&quot; << endl; return 0; } // Percolate up int hole = ++currentSize; for(; hole > 1 && x < array[hole/2 ]; hole /= 2) array[ hole ] = array[ hole / 2 ]; array[hole] = x; } http://ecomputernotes.com
Heap code in C++ template <class eType> void Heap<eType>::deleteMin( eType & minItem ) { if( isEmpty( ) ) { cout <<  &quot; heap is empty. “ << endl ; return; } minItem = array[ 1 ]; array[ 1 ] = array[ currentSize-- ]; percolateDown( 1 ); } http://ecomputernotes.com

More Related Content

What's hot

Predictive Analytics Powered By Process Mining: It’s The Process, Stupid!
Predictive Analytics Powered By Process Mining: It’s The Process, Stupid!Predictive Analytics Powered By Process Mining: It’s The Process, Stupid!
Predictive Analytics Powered By Process Mining: It’s The Process, Stupid!
Rising Media Ltd.
 

What's hot (14)

Tilting Google Maps and MissileLauncher
Tilting Google Maps and MissileLauncherTilting Google Maps and MissileLauncher
Tilting Google Maps and MissileLauncher
 
Seaborn graphing present
Seaborn graphing presentSeaborn graphing present
Seaborn graphing present
 
Exercicis selectivitat
Exercicis selectivitatExercicis selectivitat
Exercicis selectivitat
 
AI&ML Conference 2019 - Deep Learning from zero to hero
AI&ML Conference 2019 - Deep Learning from zero to heroAI&ML Conference 2019 - Deep Learning from zero to hero
AI&ML Conference 2019 - Deep Learning from zero to hero
 
Vcs23
Vcs23Vcs23
Vcs23
 
Clock For My
Clock For MyClock For My
Clock For My
 
Open Cv Tutorial Ii
Open Cv Tutorial IiOpen Cv Tutorial Ii
Open Cv Tutorial Ii
 
TC7S08F PSpice Model (Free SPICE Model)
TC7S08F PSpice Model  (Free SPICE Model)TC7S08F PSpice Model  (Free SPICE Model)
TC7S08F PSpice Model (Free SPICE Model)
 
Sary
SarySary
Sary
 
Advanced Topics in Haskell
Advanced Topics in HaskellAdvanced Topics in Haskell
Advanced Topics in Haskell
 
Sqlite
SqliteSqlite
Sqlite
 
Predictive Analytics Powered By Process Mining: It’s The Process, Stupid!
Predictive Analytics Powered By Process Mining: It’s The Process, Stupid!Predictive Analytics Powered By Process Mining: It’s The Process, Stupid!
Predictive Analytics Powered By Process Mining: It’s The Process, Stupid!
 
真っ黒Scheme
真っ黒Scheme真っ黒Scheme
真っ黒Scheme
 
Self Evaluation Test
Self Evaluation Test Self Evaluation Test
Self Evaluation Test
 

Viewers also liked

computer notes - Data Structures - 20
computer notes - Data Structures - 20computer notes - Data Structures - 20
computer notes - Data Structures - 20
ecomputernotes
 
computer notes - Data Structures - 17
computer notes - Data Structures - 17computer notes - Data Structures - 17
computer notes - Data Structures - 17
ecomputernotes
 
computer notes - Data Structures - 7
computer notes - Data Structures - 7computer notes - Data Structures - 7
computer notes - Data Structures - 7
ecomputernotes
 
computer notes - Data Structures - 5
computer notes - Data Structures - 5computer notes - Data Structures - 5
computer notes - Data Structures - 5
ecomputernotes
 
computer notes - Data Structures - 29
computer notes - Data Structures - 29computer notes - Data Structures - 29
computer notes - Data Structures - 29
ecomputernotes
 
computer notes - Data Structures - 22
computer notes - Data Structures - 22computer notes - Data Structures - 22
computer notes - Data Structures - 22
ecomputernotes
 
computer notes - Data Structures - 26
computer notes - Data Structures - 26computer notes - Data Structures - 26
computer notes - Data Structures - 26
ecomputernotes
 
computer notes - Data Structures - 8
computer notes - Data Structures - 8computer notes - Data Structures - 8
computer notes - Data Structures - 8
ecomputernotes
 
computer notes - Data Structures - 11
computer notes - Data Structures - 11computer notes - Data Structures - 11
computer notes - Data Structures - 11
ecomputernotes
 
computer notes - Data Structures - 24
computer notes - Data Structures - 24computer notes - Data Structures - 24
computer notes - Data Structures - 24
ecomputernotes
 
computer notes - Data Structures - 31
computer notes - Data Structures - 31computer notes - Data Structures - 31
computer notes - Data Structures - 31
ecomputernotes
 
computer notes - Data Structures - 34
computer notes - Data Structures - 34computer notes - Data Structures - 34
computer notes - Data Structures - 34
ecomputernotes
 
computer notes - Data Structures - 32
computer notes - Data Structures - 32computer notes - Data Structures - 32
computer notes - Data Structures - 32
ecomputernotes
 
computer notes - Data Structures - 10
computer notes - Data Structures - 10computer notes - Data Structures - 10
computer notes - Data Structures - 10
ecomputernotes
 
computer notes - Data Structures - 13
computer notes - Data Structures - 13computer notes - Data Structures - 13
computer notes - Data Structures - 13
ecomputernotes
 
computer notes - Data Structures - 15
computer notes - Data Structures - 15computer notes - Data Structures - 15
computer notes - Data Structures - 15
ecomputernotes
 
computer notes - Data Structures - 18
computer notes - Data Structures - 18computer notes - Data Structures - 18
computer notes - Data Structures - 18
ecomputernotes
 
computer notes - Data Structures - 27
computer notes - Data Structures - 27computer notes - Data Structures - 27
computer notes - Data Structures - 27
ecomputernotes
 
computer notes - Data Structures - 9
computer notes - Data Structures - 9computer notes - Data Structures - 9
computer notes - Data Structures - 9
ecomputernotes
 
computer notes - Data Structures - 1
computer notes - Data Structures - 1computer notes - Data Structures - 1
computer notes - Data Structures - 1
ecomputernotes
 

Viewers also liked (20)

computer notes - Data Structures - 20
computer notes - Data Structures - 20computer notes - Data Structures - 20
computer notes - Data Structures - 20
 
computer notes - Data Structures - 17
computer notes - Data Structures - 17computer notes - Data Structures - 17
computer notes - Data Structures - 17
 
computer notes - Data Structures - 7
computer notes - Data Structures - 7computer notes - Data Structures - 7
computer notes - Data Structures - 7
 
computer notes - Data Structures - 5
computer notes - Data Structures - 5computer notes - Data Structures - 5
computer notes - Data Structures - 5
 
computer notes - Data Structures - 29
computer notes - Data Structures - 29computer notes - Data Structures - 29
computer notes - Data Structures - 29
 
computer notes - Data Structures - 22
computer notes - Data Structures - 22computer notes - Data Structures - 22
computer notes - Data Structures - 22
 
computer notes - Data Structures - 26
computer notes - Data Structures - 26computer notes - Data Structures - 26
computer notes - Data Structures - 26
 
computer notes - Data Structures - 8
computer notes - Data Structures - 8computer notes - Data Structures - 8
computer notes - Data Structures - 8
 
computer notes - Data Structures - 11
computer notes - Data Structures - 11computer notes - Data Structures - 11
computer notes - Data Structures - 11
 
computer notes - Data Structures - 24
computer notes - Data Structures - 24computer notes - Data Structures - 24
computer notes - Data Structures - 24
 
computer notes - Data Structures - 31
computer notes - Data Structures - 31computer notes - Data Structures - 31
computer notes - Data Structures - 31
 
computer notes - Data Structures - 34
computer notes - Data Structures - 34computer notes - Data Structures - 34
computer notes - Data Structures - 34
 
computer notes - Data Structures - 32
computer notes - Data Structures - 32computer notes - Data Structures - 32
computer notes - Data Structures - 32
 
computer notes - Data Structures - 10
computer notes - Data Structures - 10computer notes - Data Structures - 10
computer notes - Data Structures - 10
 
computer notes - Data Structures - 13
computer notes - Data Structures - 13computer notes - Data Structures - 13
computer notes - Data Structures - 13
 
computer notes - Data Structures - 15
computer notes - Data Structures - 15computer notes - Data Structures - 15
computer notes - Data Structures - 15
 
computer notes - Data Structures - 18
computer notes - Data Structures - 18computer notes - Data Structures - 18
computer notes - Data Structures - 18
 
computer notes - Data Structures - 27
computer notes - Data Structures - 27computer notes - Data Structures - 27
computer notes - Data Structures - 27
 
computer notes - Data Structures - 9
computer notes - Data Structures - 9computer notes - Data Structures - 9
computer notes - Data Structures - 9
 
computer notes - Data Structures - 1
computer notes - Data Structures - 1computer notes - Data Structures - 1
computer notes - Data Structures - 1
 

Similar to computer notes - Data Structures - 25

Computer notes data structures - 9
Computer notes   data structures - 9Computer notes   data structures - 9
Computer notes data structures - 9
ecomputernotes
 
computer notes - Data Structures - 39
computer notes - Data Structures - 39computer notes - Data Structures - 39
computer notes - Data Structures - 39
ecomputernotes
 
computer notes - Data Structures - 16
computer notes - Data Structures - 16computer notes - Data Structures - 16
computer notes - Data Structures - 16
ecomputernotes
 
A Beginner's Manual for PyRx
A Beginner's Manual for PyRxA Beginner's Manual for PyRx
A Beginner's Manual for PyRx
John Cahill
 

Similar to computer notes - Data Structures - 25 (20)

Computer notes data structures - 9
Computer notes   data structures - 9Computer notes   data structures - 9
Computer notes data structures - 9
 
LEC 8-DS ALGO(heaps).pdf
LEC 8-DS  ALGO(heaps).pdfLEC 8-DS  ALGO(heaps).pdf
LEC 8-DS ALGO(heaps).pdf
 
Computer notes - Mergesort
Computer notes - MergesortComputer notes - Mergesort
Computer notes - Mergesort
 
(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart Pointers(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart Pointers
 
computer notes - Data Structures - 39
computer notes - Data Structures - 39computer notes - Data Structures - 39
computer notes - Data Structures - 39
 
Build Heap Step by Step
Build Heap Step by StepBuild Heap Step by Step
Build Heap Step by Step
 
How to master C++
How to master C++How to master C++
How to master C++
 
Saii log
Saii logSaii log
Saii log
 
The Ring programming language version 1.6 book - Part 79 of 189
The Ring programming language version 1.6 book - Part 79 of 189The Ring programming language version 1.6 book - Part 79 of 189
The Ring programming language version 1.6 book - Part 79 of 189
 
Fast and accurate metrics. Is it actually possible?
Fast and accurate metrics. Is it actually possible?Fast and accurate metrics. Is it actually possible?
Fast and accurate metrics. Is it actually possible?
 
Fatima Aliasgher Portfolio
Fatima Aliasgher PortfolioFatima Aliasgher Portfolio
Fatima Aliasgher Portfolio
 
CGo for fun and profit
CGo for fun and profitCGo for fun and profit
CGo for fun and profit
 
computer notes - Data Structures - 16
computer notes - Data Structures - 16computer notes - Data Structures - 16
computer notes - Data Structures - 16
 
리눅스 드라이버 실습 #3
리눅스 드라이버 실습 #3리눅스 드라이버 실습 #3
리눅스 드라이버 실습 #3
 
Creating Responsive Experiences
Creating Responsive ExperiencesCreating Responsive Experiences
Creating Responsive Experiences
 
Generic Setup De-Mystified
Generic Setup De-MystifiedGeneric Setup De-Mystified
Generic Setup De-Mystified
 
PAC 2020 Santorin - Andreas Grabner
PAC 2020 Santorin - Andreas Grabner PAC 2020 Santorin - Andreas Grabner
PAC 2020 Santorin - Andreas Grabner
 
A Beginner's Manual for PyRx
A Beginner's Manual for PyRxA Beginner's Manual for PyRx
A Beginner's Manual for PyRx
 
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang MeetupДоклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
 
5 Rmi Print
5  Rmi Print5  Rmi Print
5 Rmi Print
 

More from ecomputernotes

computer notes - Data Structures - 30
computer notes - Data Structures - 30computer notes - Data Structures - 30
computer notes - Data Structures - 30
ecomputernotes
 
Computer notes - Including Constraints
Computer notes - Including ConstraintsComputer notes - Including Constraints
Computer notes - Including Constraints
ecomputernotes
 
Computer notes - Date time Functions
Computer notes - Date time FunctionsComputer notes - Date time Functions
Computer notes - Date time Functions
ecomputernotes
 
Computer notes - Subqueries
Computer notes - SubqueriesComputer notes - Subqueries
Computer notes - Subqueries
ecomputernotes
 
Computer notes - Other Database Objects
Computer notes - Other Database ObjectsComputer notes - Other Database Objects
Computer notes - Other Database Objects
ecomputernotes
 
computer notes - Data Structures - 28
computer notes - Data Structures - 28computer notes - Data Structures - 28
computer notes - Data Structures - 28
ecomputernotes
 
computer notes - Data Structures - 19
computer notes - Data Structures - 19computer notes - Data Structures - 19
computer notes - Data Structures - 19
ecomputernotes
 
computer notes - Data Structures - 4
computer notes - Data Structures - 4computer notes - Data Structures - 4
computer notes - Data Structures - 4
ecomputernotes
 
Computer notes - Advanced Subqueries
Computer notes -   Advanced SubqueriesComputer notes -   Advanced Subqueries
Computer notes - Advanced Subqueries
ecomputernotes
 
Computer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group FunctionsComputer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group Functions
ecomputernotes
 
computer notes - Data Structures - 35
computer notes - Data Structures - 35computer notes - Data Structures - 35
computer notes - Data Structures - 35
ecomputernotes
 
computer notes - Data Structures - 36
computer notes - Data Structures - 36computer notes - Data Structures - 36
computer notes - Data Structures - 36
ecomputernotes
 
Computer notes - Enhancements to the GROUP BY Clause
Computer notes - Enhancements to the GROUP BY ClauseComputer notes - Enhancements to the GROUP BY Clause
Computer notes - Enhancements to the GROUP BY Clause
ecomputernotes
 
Computer notes - Manipulating Data
Computer notes - Manipulating DataComputer notes - Manipulating Data
Computer notes - Manipulating Data
ecomputernotes
 
Computer notes - Writing Basic SQL SELECT Statements
Computer notes - Writing Basic SQL SELECT StatementsComputer notes - Writing Basic SQL SELECT Statements
Computer notes - Writing Basic SQL SELECT Statements
ecomputernotes
 
computer notes - Data Structures - 14
computer notes - Data Structures - 14computer notes - Data Structures - 14
computer notes - Data Structures - 14
ecomputernotes
 
Computer notes - Controlling User Access
Computer notes - Controlling User AccessComputer notes - Controlling User Access
Computer notes - Controlling User Access
ecomputernotes
 
Computer notes - Using SET Operator
Computer notes - Using SET OperatorComputer notes - Using SET Operator
Computer notes - Using SET Operator
ecomputernotes
 
computer notes - Data Structures - 38
computer notes - Data Structures - 38computer notes - Data Structures - 38
computer notes - Data Structures - 38
ecomputernotes
 

More from ecomputernotes (19)

computer notes - Data Structures - 30
computer notes - Data Structures - 30computer notes - Data Structures - 30
computer notes - Data Structures - 30
 
Computer notes - Including Constraints
Computer notes - Including ConstraintsComputer notes - Including Constraints
Computer notes - Including Constraints
 
Computer notes - Date time Functions
Computer notes - Date time FunctionsComputer notes - Date time Functions
Computer notes - Date time Functions
 
Computer notes - Subqueries
Computer notes - SubqueriesComputer notes - Subqueries
Computer notes - Subqueries
 
Computer notes - Other Database Objects
Computer notes - Other Database ObjectsComputer notes - Other Database Objects
Computer notes - Other Database Objects
 
computer notes - Data Structures - 28
computer notes - Data Structures - 28computer notes - Data Structures - 28
computer notes - Data Structures - 28
 
computer notes - Data Structures - 19
computer notes - Data Structures - 19computer notes - Data Structures - 19
computer notes - Data Structures - 19
 
computer notes - Data Structures - 4
computer notes - Data Structures - 4computer notes - Data Structures - 4
computer notes - Data Structures - 4
 
Computer notes - Advanced Subqueries
Computer notes -   Advanced SubqueriesComputer notes -   Advanced Subqueries
Computer notes - Advanced Subqueries
 
Computer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group FunctionsComputer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group Functions
 
computer notes - Data Structures - 35
computer notes - Data Structures - 35computer notes - Data Structures - 35
computer notes - Data Structures - 35
 
computer notes - Data Structures - 36
computer notes - Data Structures - 36computer notes - Data Structures - 36
computer notes - Data Structures - 36
 
Computer notes - Enhancements to the GROUP BY Clause
Computer notes - Enhancements to the GROUP BY ClauseComputer notes - Enhancements to the GROUP BY Clause
Computer notes - Enhancements to the GROUP BY Clause
 
Computer notes - Manipulating Data
Computer notes - Manipulating DataComputer notes - Manipulating Data
Computer notes - Manipulating Data
 
Computer notes - Writing Basic SQL SELECT Statements
Computer notes - Writing Basic SQL SELECT StatementsComputer notes - Writing Basic SQL SELECT Statements
Computer notes - Writing Basic SQL SELECT Statements
 
computer notes - Data Structures - 14
computer notes - Data Structures - 14computer notes - Data Structures - 14
computer notes - Data Structures - 14
 
Computer notes - Controlling User Access
Computer notes - Controlling User AccessComputer notes - Controlling User Access
Computer notes - Controlling User Access
 
Computer notes - Using SET Operator
Computer notes - Using SET OperatorComputer notes - Using SET Operator
Computer notes - Using SET Operator
 
computer notes - Data Structures - 38
computer notes - Data Structures - 38computer notes - Data Structures - 38
computer notes - Data Structures - 38
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 

computer notes - Data Structures - 25

  • 1. Class No.25 Data Structures http://ecomputernotes.com
  • 2.
  • 3. BuildHeap i = 15/2 = 7 65 19 21 14 24 26 13 15 68 16 65 21 19 26 14 16 68 13 24 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 31 31 11 32 32 12 15 4 5 13 70 14 12 15 5 70 12 i  i Why I=n/2? http://ecomputernotes.com
  • 4. BuildHeap i = 15/2 = 7 65 19 21 14 24 26 13 15 12 16 65 21 19 26 14 16 12 13 24 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 31 31 11 32 32 12 15 4 5 13 70 14 68 15 5 70 68 i  i http://ecomputernotes.com
  • 5. BuildHeap i = 6 65 19 21 14 24 26 13 15 12 16 65 21 19 26 14 16 12 13 24 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 31 31 11 32 32 12 15 4 5 13 70 14 68 15 5 70 68 i  i http://ecomputernotes.com
  • 6. BuildHeap i = 5 65 5 21 14 24 26 13 15 12 16 65 21 5 26 14 16 12 13 24 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 31 31 11 32 32 12 15 4 19 13 70 14 68 15 19 70 68 i  i http://ecomputernotes.com
  • 7. BuildHeap i = 4 65 5 14 21 24 26 13 15 12 16 65 14 5 26 21 16 12 13 24 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 31 31 11 32 32 12 15 4 19 13 70 14 68 15 19 70 68 i  i http://ecomputernotes.com
  • 8. BuildHeap i = 3 65 5 14 21 24 13 26 15 12 16 65 14 5 13 21 16 12 26 24 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 31 31 11 32 32 12 15 4 19 13 70 14 68 15 19 70 68 i  i http://ecomputernotes.com
  • 9. BuildHeap i = 2 65 16 14 21 24 13 26 15 12 32 65 14 16 13 21 32 12 26 24 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 31 31 11 5 5 12 15 4 19 13 70 14 68 15 19 70 68 i  i http://ecomputernotes.com
  • 10. BuildHeap i = 1 65 16 14 21 31 24 26 15 12 32 65 14 16 24 21 32 12 26 31 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 13 13 11 5 5 12 15 4 19 13 70 14 68 15 19 70 68 i  i http://ecomputernotes.com
  • 11. BuildHeap Min heap 5 16 14 21 31 24 26 15 65 32 5 14 16 24 21 32 65 26 31 15 1 2 3 5 6 7 8 9 10 11 12 13 14 0 1 2 3 7 6 5 4 8 9 10 13 13 11 12 12 12 15 4 19 13 70 14 68 15 19 70 68 http://ecomputernotes.com
  • 12.
  • 13. Heap code in C++ template <class eType> class Heap { public: Heap( int capacity = 100 ); void insert( const eType & x ); void deleteMin( eType & minItem ); const eType & getMin( ); bool isEmpty( ); bool isFull( ); int Heap<eType>::getSize( ); http://ecomputernotes.com
  • 14. Heap code in C++ private: int currentSize; // Number of elements in heap eType* array; // The heap array int capacity; void percolateDown( int hole ); }; http://ecomputernotes.com
  • 15. Heap code in C++ #include &quot;Heap.h“ template <class eType> Heap<eType>::Heap( int capacity ) { array = new etype[capacity + 1]; currentSize=0; } http://ecomputernotes.com
  • 16. Heap code in C++ // Insert item x into the heap, maintaining heap // order. Duplicates are allowed. template <class eType> bool Heap<eType>::insert( const eType & x ) { if( isFull( ) ) { cout << &quot;insert - Heap is full.&quot; << endl; return 0; } // Percolate up int hole = ++currentSize; for(; hole > 1 && x < array[hole/2 ]; hole /= 2) array[ hole ] = array[ hole / 2 ]; array[hole] = x; } http://ecomputernotes.com
  • 17. Heap code in C++ template <class eType> void Heap<eType>::deleteMin( eType & minItem ) { if( isEmpty( ) ) { cout << &quot; heap is empty. “ << endl ; return; } minItem = array[ 1 ]; array[ 1 ] = array[ currentSize-- ]; percolateDown( 1 ); } http://ecomputernotes.com

Editor's Notes

  1. Star of lecture 31
  2. End of lecture 30
  3. End of lecture 31, start of 32